#include "car_power_range_ownership.hpp"
#include "csv_struct.hpp"

int car_power_range_ownership_csv::find_power_range_ownership_id(int _power_range_id, int _ownership_id)
{
	int id(static_cast<car_power_range_ownership_struct_csv>(car_power_range_ownership_csv::find(_power_range_id, _ownership_id)).id());

	std::cout<< "[car_power_range_ownership::find_power_range_ownership_id] power range and ownership id = " << id << std::endl;

	return id;
}

car_power_range_ownership_struct_csv const car_power_range_ownership_csv::find(int _id)
{
	csv_struct csv_file(file_list::car_power_range_and_ownership_filename());

	while(_id && !csv_file.eof())
	{
		++csv_file;
		car_power_range_ownership_struct_csv row(csv_file.get_line());
		if(row.id() != _id) continue;

		return row;
	}

	car_power_range_ownership_struct_csv car_power_range_ownership_struct_null;
	return car_power_range_ownership_struct_null;
}


car_power_range_ownership_struct_csv const car_power_range_ownership_csv::find(int _car_power_range_id, int _ownership_id)
{
	csv_struct csv_file(file_list::car_power_range_and_ownership_filename());

	while(_car_power_range_id && _ownership_id && !csv_file.eof())
	{
		++csv_file;
		car_power_range_ownership_struct_csv row(csv_file.get_line());

		if(row.range() != _car_power_range_id) continue;
		if(row.ownership() != _ownership_id) continue;

		return row;

	}

	car_power_range_ownership_struct_csv car_power_range_ownership_struct_null;
	return car_power_range_ownership_struct_null;
}


